#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from sqlalchemy import String,ForeignKey
from sqlalchemy.orm import Mapped, mapped_column

from backend.app.core.models.base import Base, id_key


class InstanceUser(Base):
    """系统api"""

    __tablename__ = 'dbms_instance_user'
    id: Mapped[id_key] = mapped_column(init=False)
    user_name: Mapped[str] = mapped_column(String(50), unique=True, comment='tag名称')
    user_network: Mapped[str] = mapped_column(String(50), unique=True, comment='tag代码')
    user_password: Mapped[str] = mapped_column(String(50), unique=True, comment='tag代码')
    grant_type: Mapped[int] = mapped_column(default=1, comment='角色状态（0最高权限账号1复制账号2备份账号3监控账号4应用账号5同步账号6）')
    status: Mapped[int] = mapped_column(default=1, comment='角色状态（0停用 1正常）')
    remark: Mapped[str | None] = mapped_column(String(255), comment='备注')
    instance_id: Mapped[int | None] = mapped_column(
        ForeignKey('dbms_instance.id', ondelete='SET NULL'), default=None, comment='实例关联ID'
    )
